<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <div class="mb-10">
        <div class="toplineBox">
          <div class="toplineBox-left">
            <el-input v-model="name" placeholder="名称" size="small w-140" class="mr-10"></el-input>
            <el-button type="primary" size="small" @click="searchFn('search')" class="ml-10"><i
              class="el-icon-search"></i>搜索
            </el-button>
            <el-button size="small" @click="refreshFn()"><i class="el-icon-refresh"></i>重置刷新</el-button>
          </div>
          <p class="numberline toplineBox-right">总{{ page.total }}条</p>
        </div>
      </div>
      <!--本体列表，数据 -->
      <div class="table-body">
        <div class="table-body-box">
          <el-table
            ref="multipleTable"
            :data="arryList"
            :stripe="tableStyle.tableStripe"
            :border="tableStyle.tableBorder"
            tooltip-effect="dark"
            style="width: 100%"
            header-cell-class-name="table-text-c"
            cell-class-name="table-text-c"
          >
            <el-table-column
              prop="name"
              label="名称">
              <template slot-scope="scope">
                {{ scope.row.book ? scope.row.book.name : '' }}
              </template>
            </el-table-column>
            <el-table-column
              prop="code"
              label="条形码">
            </el-table-column>
            <el-table-column
              prop="month"
              label="位置">
              <template slot-scope="scope">
                {{ scope.row.book ? scope.row.book.position : '' }}
              </template>
            </el-table-column>
            <el-table-column
              prop="update_time"
              label="报废时间">
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--工具条 分页-->
      <el-col :span="24" class="toolbar">
        <el-pagination
          background
          layout="total, prev, pager, next"
          :total="page.total"
          :page-size="page.pagesize"
          @current-change="handleSizeChange">
        </el-pagination>
      </el-col>
    </div>
  </div>
</template>

<script>
import {pagination, tableoption} from '@/utils/util.js'

import {
  damage_index
} from "@/api/admin/book"

export default {
  components: {},
  data() {
    return {
      arryList: [],
      handleSelection: [],
      // 设置table样式
      tableStyle: tableoption,
      // 设置table页面分页所需
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      name: ''
    }
  },
  created() {
    this.InitFn()
  },
  methods: {
    // 初始化
    InitFn() {
      damage_index({
        p: this.page.pageindex,
        name: this.name,
      }).then(res => {
        console.log('res', res)
        this.arryList = res.list.data
        this.page.total = res.list.total
      })
    },
    handleSelectionChange(val) {
      this.handleSelection = val
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    searchFn() {
      this.page.pageindex = 1
      this.InitFn()
    },
    // 刷新页面
    refreshFn() {
      this.page.pageindex = 1
      this.name = ''
      this.InitFn()
    },
    addStudent(option) {
      this.wagesDetail = JSON.parse(JSON.stringify(option))
      this.detailvisible = true
    },
    detelFn(id, index) {
      let self_ = this
      this.$confirm('删除当条数据信息，是否继续？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // wagesDel({
        //   id: id
        // }).then(res => {
        //   this.$message.success('删除成功')
        //   this.InitFn()
        // })
      }).catch(() => {

      })
    }
  },
  mounted() {
  }
}
</script>
